<?php
/** 
 *	代金券模型服务类
 */
class CashcouponModel extends Model {

	/**
	 * 
	 * @param string $passcode	代金券码
	 * @return array数据。格式：$cashcouponcode[]代金券码基本信息，$cashcouponcode[baseinfo]对应代金券信息
	 */
	function getInfoByCode($passcode){
		$map['passcode'] = $passcode;
  		$map['enable'] 		= 'Y';
  		$map['is_delete'] 	= 'N';
  		$cashcouponcode = M('CashcouponCode')->where($map)->find();
  		if(!empty($cashcouponcode)){
	  		$mapcc['id']			=	$cashcouponcode['cashcoupon_id'];
	  		$mapcc['enable']		= 	'Y';
	  		$mapcc['is_canceled']	=	'N';
	  		$cashcoupon = $this->where($mapcc)->find();
	  		$cashcouponcode['baseinfo']=$cashcoupon;
  		}
  		return $cashcouponcode;
	}
	
}
?>